package siga.visao_financeiro;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.visao.*;



public class cadFornecedorRapido extends javax.swing.JDialog {
    public boolean finaliza = false;
    List cod_cidade = new ArrayList();
    /** Creates new form cadFornecedorRapido */
    public cadFornecedorRapido(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        barraFerramentaFonecedor = new javax.swing.JToolBar();
        btSalvar = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jfEndereco = new javax.swing.JTextField();
        jfNr = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jfBairro = new javax.swing.JTextField();
        jfComplemento = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jfCEP = new javax.swing.JFormattedTextField();
        jLabel14 = new javax.swing.JLabel();
        jfCidade = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jfEstado = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jfPais = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        jfCNPJ = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        jfNomeFantasia = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jfDescricao = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jfEmail = new javax.swing.JTextField();
        jfTelCelular = new javax.swing.JFormattedTextField();
        jfTelLoja = new javax.swing.JFormattedTextField();
        jfTelefone = new javax.swing.JFormattedTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        barraFerramentaFonecedor.setFloatable(false);
        barraFerramentaFonecedor.setRollover(true);
        barraFerramentaFonecedor.setName("barraFerramentaFonecedor"); // NOI18N

        btSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/salvar_32x32.png"))); // NOI18N
        btSalvar.setMnemonic('S');
        btSalvar.setText("Salvar");
        btSalvar.setToolTipText("Salvar um Cadastro");
        btSalvar.setFocusable(false);
        btSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSalvar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSalvar.setName("btSalvar"); // NOI18N
        btSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSalvar);

        btCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cancelar_32x32.png"))); // NOI18N
        btCancelar.setMnemonic('C');
        btCancelar.setText("Cancelar");
        btCancelar.setToolTipText("Cancelar um Cadastro");
        btCancelar.setFocusable(false);
        btCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btCancelar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btCancelar.setName("btCancelar"); // NOI18N
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btCancelar);

        jLabel8.setText("Endereço:");
        jLabel8.setName("jLabel8"); // NOI18N

        jfEndereco.setName("jfEndereco"); // NOI18N

        jfNr.setName("jfNr"); // NOI18N

        jLabel9.setText("Número");
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setText("Bairro:");
        jLabel10.setName("jLabel10"); // NOI18N

        jfBairro.setName("jfBairro"); // NOI18N

        jfComplemento.setName("jfComplemento"); // NOI18N

        jLabel15.setText("Complemento:");
        jLabel15.setName("jLabel15"); // NOI18N

        try {
            jfCEP.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfCEP.setName("jfCEP"); // NOI18N

        jLabel14.setText("CEP:");
        jLabel14.setName("jLabel14"); // NOI18N

        jfCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Capivari de Baixo", "Tubarão" }));
        jfCidade.setName("jfCidade"); // NOI18N

        jLabel13.setText("Cidade:");
        jLabel13.setName("jLabel13"); // NOI18N

        jfEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SC", "PR", "RJ", "RS", "MG", "SP", " " }));
        jfEstado.setName("jfEstado"); // NOI18N
        jfEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jfEstadoActionPerformed(evt);
            }
        });

        jLabel12.setText("Estado:");
        jLabel12.setName("jLabel12"); // NOI18N

        jfPais.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Brasil", " " }));
        jfPais.setName("jfPais"); // NOI18N

        jLabel11.setText("País:");
        jLabel11.setName("jLabel11"); // NOI18N

        try {
            jfCNPJ.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("########/####-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfCNPJ.setName("jfCNPJ"); // NOI18N

        jLabel6.setText("CNPJ:");
        jLabel6.setName("jLabel6"); // NOI18N

        jfNomeFantasia.setName("jfNomeFantasia"); // NOI18N

        jLabel7.setText("Nome Fantasia:");
        jLabel7.setName("jLabel7"); // NOI18N

        jfDescricao.setName("jfDescricao"); // NOI18N

        jLabel4.setText("Contato:");
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel1.setText("Telefone Comercial:");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText("Telefone Loja:");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText("Telefone Celular:");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel5.setText("E-Mail:");
        jLabel5.setName("jLabel5"); // NOI18N

        jfEmail.setName("jfEmail"); // NOI18N

        try {
            jfTelCelular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##) ####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfTelCelular.setName("jfTelCelular"); // NOI18N

        try {
            jfTelLoja.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##) ####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfTelLoja.setName("jfTelLoja"); // NOI18N

        try {
            jfTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##) ####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfTelefone.setName("jfTelefone"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 690, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jfNomeFantasia, javax.swing.GroupLayout.PREFERRED_SIZE, 515, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jfCNPJ, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                    .addComponent(jLabel6))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addContainerGap(637, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jfEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jfNr)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jfBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jfPais, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jfEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(86, 86, 86)
                                .addComponent(jLabel12)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel13)
                            .addComponent(jfCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jfCEP, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15)
                            .addComponent(jfComplemento, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE))))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jfTelefone)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jfTelLoja, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jfTelCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(333, 333, 333))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jfEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE)
                        .addContainerGap())))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jfDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 670, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfNomeFantasia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2)
                        .addComponent(jLabel4))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jfCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(1, 1, 1)
                .addComponent(jfDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTelLoja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTelCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jfEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jfNr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jfBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jfPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jfCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfCEP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        dispose();
}//GEN-LAST:event_btCancelarActionPerformed

    private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
        if(!jfNomeFantasia.getText().equals("")){
            conexao.AutoIncrementa("pessoas");
            String ops = (jfCNPJ.getText().equals("        /    -  "))?"":",cpf=\""+jfCNPJ.getText()+"\"";
            ops += (jfDescricao.getText().equals(""))?"":",obs=\""+jfDescricao.getText()+"\"";
            ops += (jfTelefone.getText().equals("(  )     -    "))?"":",telefone=\""+jfTelefone.getText()+"\"";
            ops += (jfTelLoja.getText().equals("(  )     -    "))?"":",telefone_com=\""+jfTelLoja.getText()+"\"";
            ops += (jfTelCelular.getText().equals("(  )     -    "))?"":",celular=\""+jfTelCelular.getText()+"\"";
            ops += (jfEmail.getText().equals(""))?"":",email=\""+jfEmail.getText()+"\"";
            ops += (jfEndereco.getText().equals(""))?"":",logradouro=\""+jfEndereco.getText()+"\"";
            ops += (jfNr.getText().equals(""))?"":",nro_log=\""+jfNr.getText()+"\"";
            ops += (jfBairro.getText().equals(""))?"":",bairro=\""+jfBairro.getText()+"\"";
            ops += (jfCEP.getText().equals("     -   "))?"":",cep=\""+jfCEP.getText()+"\"";
            ops += (jfComplemento.getText().equals(""))?"":",comp_log=\""+jfComplemento.getText()+"\"";
            ops += (jfCidade.getSelectedIndex()==0)?"":",cod_cidade=\""+cod_cidade.get(jfCidade.getSelectedIndex())+"\"";
            conexao.Inserir("update pessoas set descricao=\""+jfNomeFantasia.getText()+"\",tipo=\"Fornecedor\" "+ops+"  where cod_emp="+index.cod_emp+" and codigo="+conexao.AutoIncRS);
            index.LRpessoa.add(0, conexao.AutoIncRS);
            index.LRpessoa.add(1, jfNomeFantasia.getText());
            conexao.AutoIncRS="";
            finaliza = true;
            dispose();
        }else{
            JOptionPane.showMessageDialog(null, "O campo Nome Fantasia é Obrigatório.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
            jfNomeFantasia.requestFocus();
        }
}//GEN-LAST:event_btSalvarActionPerformed

    private void jfEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jfEstadoActionPerformed
        CampoCidadeCarrega();
}//GEN-LAST:event_jfEstadoActionPerformed


    private void CampoEstadoCarrega(){
        try {
            conexao.Query("select codigo, sigla from end_estados order by sigla");
            jfEstado.removeAllItems();
            while (conexao.rs.next()) {
                jfEstado.addItem(conexao.rs.getString("sigla"));
            }
            jfEstado.setSelectedItem("SC");
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void CampoPaisCarrega(){
        try {
            conexao.Query("select codigo, descricao from end_pais order by descricao");
            jfPais.removeAllItems();
            while (conexao.rs.next()) {
                jfPais.addItem(conexao.rs.getString("descricao"));
            }
            jfPais.setSelectedItem("BRASIL");
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void CampoCidadeCarrega(){
        try {
            conexao.Conexao();
            conexao.Query("select codigo, descricao from end_cidade where sigla=\"" + jfEstado.getSelectedItem() + "\" order by descricao");
            jfCidade.removeAllItems();
            cod_cidade.removeAll(cod_cidade);
            while (conexao.rs.next()) {
                cod_cidade.add(conexao.rs.getString("codigo"));
                jfCidade.addItem(conexao.rs.getString("descricao"));
            }
            conexao.FechaConexao();
            jfCidade.setSelectedItem("CAPIVARI DE BAIXO");
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barraFerramentaFonecedor;
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btSalvar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jfBairro;
    private javax.swing.JFormattedTextField jfCEP;
    private javax.swing.JFormattedTextField jfCNPJ;
    private javax.swing.JComboBox jfCidade;
    private javax.swing.JTextField jfComplemento;
    private javax.swing.JTextField jfDescricao;
    private javax.swing.JTextField jfEmail;
    private javax.swing.JTextField jfEndereco;
    private javax.swing.JComboBox jfEstado;
    private javax.swing.JTextField jfNomeFantasia;
    private javax.swing.JTextField jfNr;
    private javax.swing.JComboBox jfPais;
    private javax.swing.JFormattedTextField jfTelCelular;
    private javax.swing.JFormattedTextField jfTelLoja;
    private javax.swing.JFormattedTextField jfTelefone;
    // End of variables declaration//GEN-END:variables

}
